
linewidth=1;
Un_Trace_SegmentArrayIndex={''};
     
        
        %
        % ultraslowspreadingMORBS = find(GaleDataPhysicalProperties(:,3)<15);
        % slowspreadingMORBS = find(GaleDataPhysicalProperties(:,3)<20);
        % intermediatespreadingMORBS = find(GaleDataPhysicalProperties(:,3)>40 & GaleDataPhysicalProperties(:,3)<120);
        % fastspreadingMORBS = find(GaleDataPhysicalProperties(:,3)>120);
        
        
        ultraslowspreadingMORBS = find(GaleDataPhysicalProperties(:,3)<=15);
        slowspreadingMORBS = find(GaleDataPhysicalProperties(:,3)>15 & GaleDataPhysicalProperties(:,3)<40);
        intermediatespreadingMORBS = find(GaleDataPhysicalProperties(:,3)>40 & GaleDataPhysicalProperties(:,3)<=120);
        fastspreadingMORBS = find(GaleDataPhysicalProperties(:,3)>120);
        
        AHUM = (strfind(GaleDataTextOrdered(:,2),'GAKK'));
        AHUM2 = find(not(cellfun('isempty', AHUM)));
        
         MgOcolumn = find(strcmp('MgO',PetrogenMajorElement_Strings_Extracted));
 
%%
%DataLabels = NeededOrder;
% QQQ
galeon='no';
figure(1)
close
figure(1)
FigureTitle = 'Figure14-PLAG-MajorTraceIso';
set(gcf,'name',regexprep(FigureTitle,'\_*',''))


hold on
PfracXtal=3;
YKGcharNF='-';
YKGcharPool='-';
YKGcharNF_instant='-.';
YKGcolor='black';%layerplot_color_here_fill


% runningColors_FILL=regexprep(runningColors_FILL,'reds5_2','grey7');
% runningColors_LINE=regexprep(runningColors_LINE,'reds5_2','grey7');

targetStrings_Isotopes = {'SR87_SR86'	'ND143_ND144'	'PB206_PB204'	'PB207_PB204'	'PB208_PB204'	'HF176_HF177' 'TH230_U238_ACTIVITY' 'TH230_TH232_ACTIVITY' 'U238_TH232_ACTIVITY' 'RA226_TH230_ACTIVITY'};
set(gcf, 'Units', 'Inches', 'Position',  [1.8611 2.7778 6.8472 9.7778], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])
       
IndiciesFig1_X = [10 7 7 ];

IndiciesFig1_Y = [9 9 11];


axesMajors = [9 13.5 5.5 10.5; ...
    6.5 12 5.5 10.5; ...
    6.5 12 1.25 4.5];

positions=[1 2 4];

IndiciesX = [IndiciesFig1_X];
IndiciesY = [IndiciesFig1_Y];


numcolumns = 2;
numrows = 3;%round(size(Indicies,2)/numcolumns);

for kk = 1:size(IndiciesX,1)
    for n = 1:size(IndiciesX,2)
        
        
        
        yvalue =  IndiciesY(kk,n);
        xvalue = IndiciesX(kk,n);
        
        [a,xindice]=(ismember(targetStrings_Majors(xvalue), DataLabels));
        [a,iiiy]=(ismember(targetStrings_Majors(yvalue), DataLabels));

         subaxis(numrows,numcolumns,positions(n),'SpacingHoriz',.001,'SpacingVert',.06,...
             'Margin',0.01,'Padding',0.00,'PaddingLeft',0.019,'PaddingBottom',.004,...
            'MarginBottom',.05,'MarginRight',0,'MarginLeft',0.04)
        
        
        [Xtext,Ytext,FigureTitle] = oxideLabel(xvalue,yvalue);
        xlabel([Xtext,' (wt%)'])
        ylabel([Ytext,' (wt%)'])
        
        
        
%         if n ==2
%             %MgNum_all = [0.2 .4:.1:.8];
%             MgNum_all = [.5 .6 .70 .72];
%             plotMgNumContours(upper(Xtext),upper(Ytext),[4 20],[4 20],MgNum_all)
%             
%         end
%         
        
        axis(axesMajors(n,:))
        hold on
        axis square
        
        subtitilesfix = {'A)' 'B)' 'C)' 'D)' 'E)' 'F)'} ;
        DataX = interp1( [0 1], xlim(), .1);
        DataY = interp1( [0 1], ylim(), .9 );
        text(DataX, DataY, subtitilesfix{positions(n)},'fontsize', 12,'FontName','Times New Roman')
        

        if strcmp(galeon,'yes')
            h1=plot(GaleDataOrdered(:,xindice), GaleDataOrdered(:,iiiy) ,'o','Color',grey8,'LineWidth',0.1,'MarkerSize',2,'MarkerFaceColor',grey8);% GALA14 517	Galapagos
            %plot(GaleDataOrderedTrace(:,xindice), GaleDataOrderedTrace(:,iiiy),'.', 'color','m', 'markerfacecolor','k','markersize',1) % GALA14 517	Galapagos
            h2=plot(GaleDataOrderedTrace(emorbs1,xindice), GaleDataOrderedTrace(emorbs1,iiiy) ,'o','Color',grey5,'LineWidth',0.1,'MarkerSize',2,'MarkerFaceColor',grey5); % GALA14 517	Galapagos    
        end
        

        for zz = UniqueLabels_Rows'
            i =find(ismember(runningLabels, runningLabels(zz)));
            
            plot(runningMajors(i,xvalue),runningMajors(i,yvalue),...
                runningMarkers{zz},'LineWidth',0.5,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),...
                'MarkerFaceColor',eval(runningColors_FILL{zz}),'HandleVisibility','on')
            
        end
        
   
        
        for iik=1:numberModels
                layerplot_color_here = eval(char(layerplot_color(iik)));
                layerplot_color_here_fill = eval(char(layerplot_color_fill(iik)));
                FCLineColors_here = eval(char(FCLineColors(iik)));
                mymarkersize = layerplot_markersize(iik);
                layerplot_marker_here = char(layerplot_marker(iik));
                layerplot_color_here_edge = eval(char(layerplot_color_edge(iik)));
            
                [Xtextyy,Ytextxx] = oxideLabel(xvalue,yvalue);
            
            
            
      
            if any((strfind(TabNames{iik},'SM')))==1
                
                numdatapts = size(eval(sprintf('%s(:,%g)', TabNames{iik}, xvalue)),1);
                layerplot_marker_here = SM_Markers;
                
                
                for lll = 1:numdatapts
                    
                    
                        mymarkersize = SM_MarkerSize(lll) ;
              
                    if ismember(lll,which2plot)
                        plot(eval(sprintf('%s(lll,%g)', TabNames{iik}, xvalue)),eval(sprintf('%s(lll,%g)', TabNames{iik}, yvalue)),...
                            char(layerplot_marker_here(lll)),'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,...
                             'MarkerEdgeColor',layerplot_color_here_edge,...
                            'LineWidth',1,'MarkerSize',mymarkersize)
                    end
                end
            else
                
         
                    
                    
                    
                    plot(eval(sprintf('%s(:,%g)', TabNames{iik}, xvalue)),eval(sprintf('%s(:,%g)', TabNames{iik}, yvalue)),layerplot_marker_here,...
                        'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,...
                        'MarkerEdgeColor',layerplot_color_here_edge,...
                        'LineWidth',1,'MarkerSize',mymarkersize)
             
            end
        end
        
        
        
        
        if isempty(NamesForFC) ==0
            for kjm = 1:size(NamesForFC,2)
                goodTabNames2=NamesForFC(kjm);
                
                [a2,b2]=find(ismember(TabNames,goodTabNames2));
                majorsHere = eval(sprintf('%s', TabNames{b2}));
               
                traceHere = eval(sprintf('%s_Trace', TabNames{b2}));
                traceHere(:,44)= 0.*traceHere(:,43);
                
                
                if ischar(layerplot_color{b2})==1
                    layerplot_color_here = eval(char(layerplot_color(b2)));
                else
                    layerplot_color_here = layerplot_color{b2};
                end
                
                if ischar(layerplot_color_fill{b2})==1
                    layerplot_color_here_fill = eval(char(layerplot_color_fill(b2)));
                      FCLineColors_here = eval(char(FCLineColors(b2)));
                else
                    layerplot_color_here_fill = layerplot_color_fill{b2};
                end
                
                
                linewidthFC = 1;
      
                    for layerplotnumXX = downsampeld
                     
                        clear testfrac testYYY
                        [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHere(layerplotnumXX,:),PetrogenMajorElement_Strings_Extracted,PfracXtal, traceHere(layerplotnumXX,:),Dmatrix);
                        %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 0.001, traceHere(layerplotnumXX,:),Dmatrix);
                        f= [testfrac(:,MgOcolumn)];
                        val = 6;%5.5; %value to find
                        %val = 6;%5.5; %value to find
                        tmp = abs(f-val);
                        [idx idy] = min(tmp); %index of closest value
                        closest = idy;
                        %plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),'-','Color',cadmiumgreen,'LineWidth',linewidthFC,'MarkerSize',.1)%'Color',airsuperiorityblue,'MarkerFaceColor',airsuperiorityblue,'MarkerSize',markersize)
                        
                        
                        
                        
                        
                        
                 
                        if ismember(layerplotnumXX,[1 2 3])==1
                            plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),YKGcharNF,'Color',FCLineColors_here,'LineWidth',1)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                        else if ismember(layerplotnumXX,[10 11])==1
                                plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),YKGcharPool,'Color',FCLineColors_here,'LineWidth',3)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                            else if ismember(layerplotnumXX,[4 5 6])==1
                                    plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),YKGcharNF,'Color',FCLineColors_here,'LineWidth',1)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                else if ismember(layerplotnumXX,[7 8 9])==1
                                    plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),YKGcharNF,'Color',red,'LineWidth',1)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                    
                                end
                            end
                            end
                        end
                        
                        
                        
                        %         clear testfrac testYYY
                        %         %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnum,:), 6, traceHere(layerplotnum,:),Dmatrix);
                        %         [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 6, traceHere(layerplotnumXX,:),Dmatrix);
                        %         f= [testfrac(:,6)];
                        %         val = 6;%5.5; %value to find
                        %         tmp = abs(f-val);
                        %         [idx idy] = min(tmp); %index of closest value
                        %         closest = idy;
                        %         plot(testfrac(1:closest,xindice), testfrac(1:closest,iiiy),'-.','Color','k','LineWidth',linewidthFC)%'Color',airsuperiorityblue,'MarkerFaceColor',airsuperiorityblue,'MarkerSize',markersize
                        %
               
                end
            end
        end
        
        
        
        
   
        
        
        if strcmp(galeon,'yes')==1
            Data_GALE_colors = {'grey4','grey55','black'};
            for ihk = 1:size(Data_GALE_colors,2)
                plot(Avg_Gale(ihk,xvalue),Avg_Gale(ihk,yvalue), 'xk','MarkerSize',15, 'LineWidth',3,'Color',eval(Data_GALE_colors{ihk}),'MarkerFaceColor',eval(Data_GALE_colors{ihk}));
            end
            
             Data_GALE_colors = {'fuschia','fuschia','fuschia'};
            Data_GALE_symbol = {'s','v','^'};
            for ihk = 1:size(Data_GALE_colors,2)
                plot(Avg_Gale(ihk,xvalue),Avg_Gale(ihk,yvalue), Data_GALE_symbol{ihk},'MarkerSize',15, 'LineWidth',1,'Color',black,'MarkerFaceColor',eval(Data_GALE_colors{ihk}));
            end
        
        end
           
        
        box on
        ax = gca;
        ax.XAxis.MinorTick = 'on';
        increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
        ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
        ax.YAxis.MinorTick = 'on';
        increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
        
      if strcmp(Ytext,'Na_2O')
            set(gca, 'Ytick',0:.5:10)
            increment = .25;
            ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
        end
        
        ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
        
        
                    if strcmp(Xtext,'FeO')
            set(gca, 'Xtick',0:1:20)
            increment = .5;
            ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
             end
        
              if strcmp(Xtext,'CaO')
            set(gca, 'Xtick',0:1:20)
            increment = 0.5;
            ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
             end
        
        if strcmp(Ytext,'MgO')
            set(gca, 'Ytick',0:1:20)
            ax.YAxis.MinorTickValues=  [0:0.5:20];
        end
        
        if strcmp(galeon,'yes')==1
            uistack(h2,'bottom')
            uistack(h1,'bottom')
        end
        
        if ismember(n,[6])
            set(gca,'yscale','log')
        end
    end
end



%%



% QQQ
masterratios = [11 6];

axesMinors = [.7 2.3 .25 3.5
    ];

Xticks = {[ .4 .8 1:.2:5]};

Yticks = {[0.05 0.25:.25:1 1:.5:4]};

Yticks = {[.2:.2:.8 1:.4:6]};





logon = 1;
for n = 1

    subaxis(numrows,numcolumns,3)
    axis(axesMinors(n,:))
    hold on
    axis square
    
    
    subtitilesfix = {'A)' 'B)' 'C)' 'D)' 'E)' 'F)'} ;
    DataX = interp1( [0 1], xlim(), .01);
    DataY = interp1( [0 1], ylim(), .7 );
    text(DataX, DataY, subtitilesfix{3},'fontsize', 12,'FontName','Times New Roman')
    
    
    
    
    xxvalue = masterratios(n,1);
    yyvalue = masterratios(n,2);
    

            
            test1 = hline(1,'k-');
            test2=vline(1,'k-');
            uistack(test1,'bottom')
            uistack(test2,'bottom')
            
            
            %             test1 = hline(DataRatios_TraceDMM(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),'k-');
            %             test2=vline(DataRatios_TraceDMM(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),'k-');
            %             uistack(test1,'bottom')
            %             uistack(test2,'bottom')
            
            if strcmp(galeon,'yes')==1
                h1=plot(DataRatios_GALEsheet(:,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios_GALEsheet(:,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue)...
                    ,'o','Color',grey8,'LineWidth',0.1,'MarkerSize',3,'MarkerFaceColor',grey8,'handlevisibility','off');
                
                h2=plot(DataRatios_GALEsheet(emorbs1,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios_GALEsheet(emorbs1,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue)...
                    ,'o','Color',grey6,'LineWidth',0.1,'MarkerSize',3,'MarkerFaceColor',grey6,'handlevisibility','off');
                
            end
            plot(kimberlites_DataRatios(:,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),kimberlites_DataRatios(:,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue)...
                ,'o','Color','r','LineWidth',0.1,'MarkerSize',3,'MarkerFaceColor','r','handlevisibility','off');
            
            
            for zz = UniqueLabels_Rows'
                i =find(ismember(runningLabels, runningLabels(zz)));
                
                plot(RawTraceDataRatios(i,xxvalue)./DataRatios_TraceElements4Normalization(normalizationColumn,xxvalue),...
                    RawTraceDataRatios(i,yyvalue)./DataRatios_TraceElements4Normalization(normalizationColumn,yyvalue),...
                    runningMarkers{zz},'LineWidth',0.5,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'HandleVisibility','on')
                
            end
            
            % emorb : grey2 #3
            % nmorb: grey55 #1
            % dmorb grey7 #2
            
            if strcmp(galeon,'yes')==1
                Data_GALE_colors = {'grey4','grey55','black'};
                
                for i = 1:size(Avg_Gale,1)
                    plot(Avg_Gale_DataRatios(i,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),Avg_Gale_DataRatios(i,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                        'xk','LineWidth',3,'MarkerSize',15, 'Color',eval(Data_GALE_colors{i}),'MarkerFaceColor',eval(Data_GALE_colors{i}),'handlevisibility','off');
                    %'o-k','LineWidth',1,'MarkerSize',12, 'Color','k','MarkerFaceColor',eval(Colors_GALE{i}));
                end
                
                Data_GALE_colors = {'fuschia','fuschia','fuschia'};
                Data_GALE_symbol = {'s','v','^'};
                
                for i = 1:size(Avg_Gale,1)
                    plot(Avg_Gale_DataRatios(i,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),Avg_Gale_DataRatios(i,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                        Data_GALE_symbol{i},'LineWidth',1,'MarkerSize',15, 'Color',black,'MarkerFaceColor',eval(Data_GALE_colors{i}),'handlevisibility','off');
                    %'o-k','LineWidth',1,'MarkerSize',12, 'Color','k','MarkerFaceColor',eval(Colors_GALE{i}));
                end
                
            end
            
           
              
                
            
            
            plot(kimberlites_DataRatios(:,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),kimberlites_DataRatios(:,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'o','Color','r','LineWidth',0.1,'MarkerSize',4,'MarkerFaceColor','r');
            
            
            
            
            for iik=1:numberModels
                
                layerplot_color_here = eval(char(layerplot_color(iik)));
                layerplot_color_here_fill = eval(char(layerplot_color_fill(iik)));
                FCLineColors_here = eval(char(FCLineColors(iik)));
                mymarkersize = layerplot_markersize(iik);
                layerplot_marker_here = char(layerplot_marker(iik));
                layerplot_color_here_edge = eval(char(layerplot_color_edge(iik)));
                
                if any((strfind(TabNames{iik},'SM')))==1
                    numdatapts = size(eval(sprintf('DataRatios_%s(:,%g)', TabNames{iik}, xxvalue)),1);
                    layerplot_marker_here = SM_Markers;
                  
                    mymarkersizeSpecial = 3;
                    for lll = 1:numdatapts
                        if ismember(lll,which2plot)
                            mymarkersize = SM_MarkerSize(lll) ;
                            plot(eval(sprintf('DataRatios_%s(lll,%g)', TabNames{iik}, xxvalue))./TraceElements4Normalization_DataRatios(xxvalue),eval(sprintf('DataRatios_%s(lll,%g)', ...
                                TabNames{iik}, yyvalue))./TraceElements4Normalization_DataRatios(yyvalue),char(layerplot_marker_here(lll)),...
                                'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'LineWidth',linewidth,'MarkerSize',mymarkersize,'HandleVisibility','off')
                       
                            
                        end
                    end
                else
                    

                        plot(eval(sprintf('DataRatios_%s(:,%g)', TabNames{iik}, xxvalue))./TraceElements4Normalization_DataRatios(xxvalue),eval(sprintf('DataRatios_%s(:,%g)', TabNames{iik}, yyvalue))./TraceElements4Normalization_DataRatios(yyvalue),...
                            layerplot_marker_here,...
                            'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'MarkerEdgeColor',layerplot_color_here_edge,'MarkerSize',mymarkersize)
 
                    
   
                end
            end
            
            
            colorindex = 1;
            for iiill = 1% suball
                %indexforlenged(iii) = RidgesListIndex{iii}(1);
                clear datasmoosh;
                for jjj=1:size(Un_Trace_SegmentArrayIndex{iiill},2) %160;%
                    plot(DataRatios_GALEsheet(unique_idx_trace{Un_Trace_SegmentArrayIndex{iiill}(jjj)},xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
                        DataRatios_GALEsheet(unique_idx_trace{Un_Trace_SegmentArrayIndex{iiill}(jjj)},yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                        'o', 'color','k', 'markerfacecolor',colorsjetTrace(colorindex,:),'markersize',5) % GALA14 517	Galapagos
                    % 'o', 'color',grey5, 'markerfacecolor',white,'markersize',8,'HandleVisibility','off') % GALA14 517	Galapagos
                    
                    %mostprimitivesmoosh = MostPrimitiveGaleDataIndex(RidgesListIndex{iii});
                    %plot(MostPrimitiveGaleData(RidgesListIndex{iii}(jjj),xindice), MostPrimitiveGaleData(RidgesListIndex{iii}(jjj),i),'p', 'color',colorsjet(colorindex,:), 'markerfacecolor',colorsjet(colorindex,:),'markersize',10) % GALA14 517	Galapagos
                    colorindex = colorindex+1;
                end
            end
            
            
            %             if isempty(NamesForFC) ==0
            %                 for kjm = 1:size(NamesForFC,2)
            %                     goodTabNames2=NamesForFC(kjm);
            %
            %                     [a2,b2]=find(ismember(TabNames,goodTabNames2));
            %                     majorsHere = eval(sprintf('%s', TabNames{b2}));
            %                     columnsarg = [ 3 4 5 6 7 9 10 12 11 13];
            %                     majorsHereRightOrder = majorsHere(:,columnsarg);
            %                     majorsHereRightOrder(isnan(majorsHereRightOrder))=0;
            %                     traceHere = eval(sprintf('%s_Trace', TabNames{b2}));
            %                     traceHere(:,44)= 0.*traceHere(:,43);
            %                     if strcmp(FC,'on') == 1
            %                         for layerplotnumXX = downsampeld
            %
            %
            %                             if layerplotnumXX==20 %any((strfind(TabNames{kjm},'gar')))==1
            %
            %                                 clear testfrac testYYY
            %                                 %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnum,:), 6, traceHere(layerplotnum,:),Dmatrix);
            %                                 [testfrac,testXXX,testYYY] = YKG_wTRACE_gar(majorsHereRightOrder(layerplotnumXX,:), 0.001, traceHere(layerplotnumXX,:),Dmatrix);
            %                                 f= [testfrac(:,6)];
            %                                 val = 6; %value to find
            %                                 tmp = abs(f-val);
            %                                 [idx idy] = min(tmp); %index of closest value
            %                                 closest = idy;
            %                                 clear DataRatios
            %                                 for gg = 1:size(ElementRatios,1)
            %                                     DataRatios(:,gg) = testXXX(:,ElementRatiosIndex(gg,1)) ./testXXX(:,ElementRatiosIndex(gg,2));
            %                                     DataRatios(:,21) = 2.*(testXXX(:,EuCol)./0.154)./((testXXX(:,SmCol)./0.406)+(testXXX(:,GdCol)./0.544));
            %                                 end
            %
            %                                 plot(DataRatios(1:closest,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios(1:closest,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                                     '.-','Color','k','LineWidth',3);
            %
            %
            %                                 clear testfrac testYYY
            %                                 %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnum,:), 6, traceHere(layerplotnum,:),Dmatrix);
            %                                 [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 0.001, traceHere(layerplotnumXX,:),Dmatrix);
            %                                 f= [testfrac(:,6)];
            %                                 val = 6; %value to find
            %                                 tmp = abs(f-val);
            %                                 [idx idy] = min(tmp); %index of closest value
            %                                 closest = idy;
            %                                 clear DataRatios
            %                                 for gg = 1:size(ElementRatios,1)
            %                                     DataRatios(:,gg) = testXXX(:,ElementRatiosIndex(gg,1)) ./testXXX(:,ElementRatiosIndex(gg,2));
            %                                     DataRatios(:,21) = 2.*(testXXX(:,EuCol)./0.154)./((testXXX(:,SmCol)./0.406)+(testXXX(:,GdCol)./0.544));
            %                                 end
            %
            %                                 plot(DataRatios(1:closest,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios(1:closest,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                                     '-','Color','k','LineWidth',3);
            %
            %
            %                             else
            %                                 clear testfrac testYYY
            %                                 %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnum,:), 6, traceHere(layerplotnum,:),Dmatrix);
            %                                 [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 0.001, traceHere(layerplotnumXX,:),Dmatrix);
            %
            %
            %
            %                                 f= [testfrac(:,6)];
            %                                 val = 6; %value to find
            %                                 tmp = abs(f-val);
            %                                 [idx idy] = min(tmp); %index of closest value
            %                                 closest = idy;
            %                                 %testXXX(:,44)=[];
            %                                 clear DataRatios
            %                                 for gg = 1:size(ElementRatios,1)
            %                                     DataRatios(:,gg) = testXXX(:,ElementRatiosIndex(gg,1)) ./testXXX(:,ElementRatiosIndex(gg,2));
            %                                     DataRatios(:,21) = 2.*(testXXX(:,EuCol)./0.154)./((testXXX(:,SmCol)./0.406)+(testXXX(:,GdCol)./0.544));
            %                                 end
            %                                 plot(DataRatios(1:closest,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios(1:closest,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                                     '-','Color','k','LineWidth',3);
            %
            %                                 clear testfrac testYYY
            %                                 [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 6, traceHere(layerplotnumXX,:),Dmatrix);
            %                                 f= [testfrac(:,6)];
            %                                 tmp = abs(f-val);
            %                                 [idx idy] = min(tmp); %index of closest value
            %                                 closest = idy;
            %                                 %testXXX(:,44)=[];
            %                                 clear DataRatios
            %                                 for gg = 1:size(ElementRatios,1)
            %                                     DataRatios(:,gg) = testXXX(:,ElementRatiosIndex(gg,1)) ./testXXX(:,ElementRatiosIndex(gg,2));
            %                                     DataRatios(:,21) = 2.*(testXXX(:,EuCol)./0.154)./((testXXX(:,SmCol)./0.406)+(testXXX(:,GdCol)./0.544));
            %                                 end
            %
            %
            %                                 % plot(DataRatios(1:closest,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),DataRatios(1:closest,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                                 %      '.-','Color','k','LineWidth',3);
            %                             end
            %                         end
            %                     end
            %                 end
            %             end
            
            
            
            
            
            %             plot(DataRatios_Chauvel_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
            %                 DataRatios_Chauvel_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                 'sk','LineWidth',1,'MarkerSize',10, 'Color',black,'MarkerFaceColor',black,'handlevisibility','off');
      
            
            plot(DataRatios_MK91_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
                DataRatios_MK91_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'sk','LineWidth',1,'MarkerSize',8, 'Color',black,'MarkerFaceColor','none','handlevisibility','off');
            
            text(DataRatios_MK91_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue)-.03,...
                DataRatios_MK91_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'MO','FontName','Times New Roman','HorizontalAlignment','right');
            
            %             plot(DataRatios_HSDM_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
            %                 DataRatios_HSDM_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
            %                 'sk','LineWidth',1,'MarkerSize',10, 'Color',black,'MarkerFaceColor',black,'handlevisibility','off');
            %xline(DataRatios_HSDM_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),'k--','HS96','FontName','Times New Roman','LabelVerticalAlignment','bottom','LabelHorizontalAlignment','left');
            
            
            plot(DataRatios_Brown2020_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
                DataRatios_Brown2020_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'sk','LineWidth',1,'MarkerSize',8, 'Color','black','MarkerFaceColor','none','handlevisibility','off');
            
            text(DataRatios_Brown2020_TraceElements4Normalization(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue)-.03,...
                DataRatios_Brown2020_TraceElements4Normalization(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'TS','FontName','Times New Roman','HorizontalAlignment','right');
            
            
            
            
            plot(DataRatios_TraceDMM(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
                DataRatios_TraceDMM(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'ko','LineWidth',1,'MarkerSize',12, 'Color',black,'MarkerFaceColor','none','handlevisibility','off');
            text(DataRatios_TraceDMM(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue)-.04,...
                DataRatios_TraceDMM(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                'WH','FontName','Times New Roman','HorizontalAlignment','right');
            
            plot(1,...
                1,...
                'ok','LineWidth',1,'MarkerSize',8, 'Color',black,'MarkerFaceColor','none','handlevisibility','off');
            text(1-.04,...
                1,...
                'PUM','FontName','Times New Roman','HorizontalAlignment','right');
            
            
            
            
            
            xlabel(sprintf('%s_{%s}',RatioLabels{xxvalue}, normalizationLabel));
            ylabel(sprintf('%s_{%s}',RatioLabels{yyvalue}, normalizationLabel));
            
            
            box on
            
            axis square
            if logon ==1
                set(gca,'yscale','log')
                set(gca,'xscale','log')
            end
            
            %set(gca, 'Xtick',1500:10:1540)
            ax = gca;
            
            set(gca, 'Ytick',unique([axesMinors(n,3:4) Yticks{n}]))
            set(gca, 'Xtick',unique([axesMinors(n,1:2) Xticks{n}]))
            
            curtick = get(gca, 'XTick');
            set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
            
            curtick = get(gca, 'YTick');
            set(gca, 'YTickLabel', cellstr(num2str(curtick(:))));
            
            
        if n == 1
       ax.XAxis.MinorTickValues = [.6:.1:10];%[2:1:axesMinors(n,2)]
                ax.XAxis.MinorTickValues = [.6:.1:1 1.5:0.5:20];%[2:1:axesMinors(n,2)]
                     ax.XAxis.MinorTickValues = [.6:.1:1 1.1:0.1:20];%[2:1:axesMinors(n,2)]
                       ax.YAxis.MinorTickValues = [.25:.05:1 1.25:.25:6];%[2:1:axesMinors(n,2)]
                        ax.YAxis.MinorTickValues = [.2:.1:1 1.2:.2:6];%[2:1:axesMinors(n,2)]
          
            end
            
            
            %  ax.XAxis.MinorTick = 'on';
            %     increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
            %  ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
            %set(ax,'XMinorTick','on')
            
            %set(gca, 'Ytick',[.4 .6 .8  1 1.2 1.4  1.6 1.8 2 2.2 3 ])
            
            %
            %             if logon ==1
            %                 set(gca,'yscale','log')
            %                 set(gca,'xscale','log')
            %             end
            
            % if n == 3
            %
            %    ax.YAxis.MinorTickValues = [[axesMinors(n,1):.001:.01] [.02:.1:3] ];%[2:1:axesMinors(n,2)]
            % end
        end
%     end
%     
%     
%     
% end



%
% legendkey2 = {'all MORB','all E-MORB','S. Af. kimberlites'};
% legendkey3 = {'avg. N-MORB','avg. D-MORB','avg. E-MORB'};
% legendkey= {legendkey2{:} UniqueLabels{:} legendkey3{:}  names4legend{:}};
% hlegned = legend(legendkey,'location','Best');
%


%
% legendkey= {UniqueLabels{:}  names4legend{:}};
% hlegned = legend(legendkey,'location','Best');
% set(hlegned,'FontSize',8)
% %set(hlegned,'position',[0.7175 0.1621 0.2368 0.2776])
%

%%



% QQQ
IndiciesFig1_X = {...
    'Na2O'
    };



IndiciesFig1_Y = {...
    'TH230_U238_ACTIVITY'
    };


% axesMajors = [3 11 6 12; 3 11 48 55  ;...
%     3 11 .5 3 ; 3 11 15 21
%     3 11 7 12; 3 11 0.2 1.4];

IndiciesX = upper(IndiciesFig1_X);
IndiciesY = upper(IndiciesFig1_Y);


zza=1;


for kk = 1:size(IndiciesX,1)%size(StableIndex,2)
    for n = 1:size(IndiciesX,2)%size(Indicies,2)
        
        
        yvalue =  IndiciesY(kk,n);
        xvalue = IndiciesX(kk,n);
        
        [a,xindice]=(ismember(xvalue, upper(Elements)));
        [a,iiiy]=(ismember(yvalue, upper(targetStrings_Isotopes)));
        
        
        subaxis(numrows,numcolumns,6)
          axis([.95 1.25 1.25 4.5])
        hold on
        axis square
        
        subtitilesfix = {'A)' 'B)' 'C)' 'D)' 'E)' 'F)'} ;
        DataX = interp1( [0 1], xlim(), .05);
        DataY = interp1( [0 1], ylim(), .9 );
        text(DataX, DataY, subtitilesfix{6},'fontsize', 12,'FontName','Times New Roman')
        
        
        
        
        for zz = UniqueLabels_Rows'
            i =find(ismember(runningLabels, runningLabels(zz)));
            
            plot(RawIsotopes(i,iiiy),...
                runningMajors(i,xindice),...
                runningMarkers{zz},'LineWidth',0.5,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'HandleVisibility','on')
        end
        
        
        
        
        
        for iik=1:numberModels
                layerplot_color_here = eval(char(layerplot_color(iik)));
                layerplot_color_here_fill = eval(char(layerplot_color_fill(iik)));
                FCLineColors_here = eval(char(FCLineColors(iik)));
                mymarkersize = layerplot_markersize(iik);
                layerplot_marker_here = char(layerplot_marker(iik));
                layerplot_color_here_edge = eval(char(layerplot_color_edge(iik)));
            
            
  

            if any((strfind(TabNames{iik},'SM')))==1
                
                numdatapts = size(eval(sprintf('%s(:,%g)', TabNames{iik}, xindice)),1);
                layerplot_marker_here = SM_Markers;
                
                
                for lll = 1:numdatapts
                    
              
                        mymarkersize = SM_MarkerSize(lll) ;
             
                    if ismember(lll,which2plot)
                        plot(eval(sprintf('%s_DISEQ(lll,3)', TabNames{iik})),eval(sprintf('%s(lll,%g)', TabNames{iik}, xindice)),...
                            char(layerplot_marker_here(lll)),'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'LineWidth',.5,'MarkerSize',mymarkersize)
                    end
                end
            else
                
                
               
                    
                        plot(eval(sprintf('%s_DISEQ(:,3)', TabNames{iik})),eval(sprintf('%s(:,%g)', TabNames{iik}, xindice)),...
                            layerplot_marker_here,...
                            'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'MarkerEdgeColor',layerplot_color_here_edge,...
                            'LineWidth',1,'MarkerSize',mymarkersize)
                        
                        
                        
                        plot(eval(sprintf('%s_DISEQ(:,1)', TabNames{iik})),eval(sprintf('%s(:,%g)', TabNames{iik}, xindice)),...
                            layerplot_marker_here,...
                            'Color',classicrose,'MarkerFaceColor',classicrose,'MarkerEdgeColor',layerplot_color_here_edge,...
                            'LineWidth',.2,'MarkerSize',mymarkersize)
    
            end
        end
        
        
        
        
        if isempty(NamesForFC) ==0
            for kjm = 1:size(NamesForFC,2)
                goodTabNames2=NamesForFC(kjm);
                
                [a2,b2]=find(ismember(TabNames,goodTabNames2));
                majorsHere = eval(sprintf('%s', TabNames{b2}));
               
                traceHere = eval(sprintf('%s_Trace', TabNames{b2}));
                traceHere(:,44)= 0.*traceHere(:,43);
                
                
                if ischar(layerplot_color{b2})==1
                    layerplot_color_here = eval(char(layerplot_color(b2)));
                else
                    layerplot_color_here = layerplot_color{b2};
                end
                
                if ischar(layerplot_color_fill{b2})==1
                    layerplot_color_here_fill = eval(char(layerplot_color_fill(b2)));
                      FCLineColors_here = eval(char(FCLineColors(b2)));
                      
                else
                    layerplot_color_here_fill = layerplot_color_fill{b2};
                end
                
                
                linewidthFC = 1;
      
                    for layerplotnumXX = downsampeld
                        
                        clear testfrac testYYY
                        [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHere(layerplotnumXX,:),PetrogenMajorElement_Strings_Extracted,PfracXtal, traceHere(layerplotnumXX,:),Dmatrix);
                        %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnumXX,:), 0.001, traceHere(layerplotnumXX,:),Dmatrix);
                        
                        f= [testfrac(:,MgOcolumn)];
                        val = 6;%5.5; %value to find
                        %val = 6;%5.5; %value to find
                        tmp = abs(f-val);
                        [idx idy] = min(tmp); %index of closest value
                        closest = idy;
                        
                        %eval(sprintf('%s(:,%g)', TabNames{iik}, xindice))
                        
                        %                           if layerplotnumXX==7
                        %                             testfrac(1:closest,9)
                        %                             eval(sprintf('%s_DISEQ(layerplotnumXX,3)', TabNames{b2})).*ones(closest,1)
                        %                           end
                        
                        
                        
                        
             
                        if ismember(layerplotnumXX,[1 2 3])==1
                            plot(eval(sprintf('%s_DISEQ(layerplotnumXX,3)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF,'Color',...
                                FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                            
                            plot(eval(sprintf('%s_DISEQ(layerplotnumXX,1)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF_instant,'Color',...
                                FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                            
                        else   if ismember(layerplotnumXX,[10 11])==1
                                plot(eval(sprintf('%s_DISEQ(layerplotnumXX,3)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharPool,'Color',...
                                    FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                
                                plot(eval(sprintf('%s_DISEQ(layerplotnumXX,1)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF_instant,'Color',...
                                    FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                
                                
                            else if ismember(layerplotnumXX,[4 5 6])==1
                                    
                                    plot(eval(sprintf('%s_DISEQ(layerplotnumXX,3)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF,'Color',...
                                        FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                    
                                    plot(eval(sprintf('%s_DISEQ(layerplotnumXX,1)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF_instant,'Color',...
                                        FCLineColors_here,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                    
                                else if ismember(layerplotnumXX,[7 8 9])==1
                                        
                                        plot(eval(sprintf('%s_DISEQ(layerplotnumXX,3)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF,'Color',...
                                            red,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                        
                                        plot(eval(sprintf('%s_DISEQ(layerplotnumXX,1)', TabNames{b2})).*ones(closest,1), testfrac(1:closest,9),YKGcharNF_instant,'Color',...
                                            red,'LineWidth',2)%'Color',airsuperiorityblack,'MarkerFaceColor',airsuperiorityblack,'MarkerSize',markersize)
                                        
                                        
                            
                                end
                            end
                        end
                        
                        
                    end
                end
            end
        end
        
        
        
        
        
        
        
        %[Xtext,Ytext,FigureTitle] = oxideLabel(xindice,1);
        ylabel('Na_2O (wt%)');
        xlabel('(^{230}Th/^{238}U)');
        
        box on
        
        ax = gca;
        
        % increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
        % ax.XAxis.MinorTickValues = ax.XLim(1):0.05:ax.XLim(2);
        
        set(gca, 'Xtick',0:.1:5)
        ax.XAxis.MinorTick = 'on';
        ax.XAxis.MinorTickValues = 0:0.05:5;
        
        % ax.YAxis.MinorTick = 'on';
        % increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
        % ax.YAxis.MinorTickValues = ax.YLim(1):.05:ax.YLim(2);
        
     if strcmp(xvalue,'NA2O')
            set(gca, 'Ytick',0:.5:10)
            increment = .25;
            
        end
        ax.YAxis.MinorTick = 'on';
        ax.YAxis.MinorTickValues = 0:increment:60;
        
        legendadd = sprintf('Net-element-frac \n in light grey');
        text(1.5,4,legendadd,'fontsize', 12,'FontName','Times New Roman','Color',grey5)
        %set(gcf,'position',[2.7917 3.4306 9.7361 9.3750])
        % OPTION: uncomment for single (non-subplot plots)
        % legend(TabNames,'location','best')
        % title(FigureTitle)
        % FigureTitle = regexprep(FigureTitle,'\_*','');
        % FigureTitle = regexprep(FigureTitle,'\/','-');
        %         FigureTitle = 'Major_Isotope_ALL';
        %         set(gcf,'name',regexprep(FigureTitle,'\_*',''))
        
        %   if ismember(zz,[6])
        %        set(gca,'yscale','log')
        %   end
        zza=zza+1;
        
    end
end

%%
UniqueLabel2={...
    'EarthChem EPR'
    'N-MORB Sims02'
    'N-MORB Sims03'
    'Siq. Perfit96'
    'Siq. Perfit96 Expt'
    'Waters13'
    'Lam. D-MORB Lund.99'
    'Siq. D-MORB Lund.99'
    'EPR Sm/Yb_{PUM}>1.5'
    'Waters11'
    'Siq. E-MORB Lund.99'
    '"ALV2390-001'
    'E-MORB Volpe93'};

UniqueLabel2={...
'All EarthChem';
    'S.T. P96';
    'S.T. L99';
    'L.S. L99';
    'L/S/W';
    'E/N W11';
    'Sm/Yb>1.5 EC';
    'S.T. L99';
    'ALV2390-1';
    'W11';
    '54-2 V93'};

%'Local-Elem-Frac'; 'Net-Elem-Frac'};


%legendkey= {UniqueLabel2{:}  names4legend{:}};
legendkey= {UniqueLabel2{:}};
hlegned = legend(legendkey,'location','Best');
set(hlegned,'FontSize',12, 'FontName','Times New Roman')
%set(hlegned,'position',[0.5125 0.2967 0.1702 0.1929])1300




% legendgoodies = {'all MORB','E-MORB','N-MORB','D-MORB'};
%
%
%   hlegend = legend([ UniqueLabels' names4legend{:}],'location','Best');
%   set(hlegend, 'Position',[0.1899 0.7890 0.2596 0.1657])
%
%


%%


% QQQ

IndiciesFig1_X = {...
    'U'  'U'; ...
    };

IndiciesFig1_Y = {...
    'Na2O'  'Na2O'; ...
    };

Xticks = {[ .4 1 10 50];
    [0.1 1 10]};

Yticks = {[0.01 0.1 1 10 20];
    [0.5 1:.2:2 3]};

axesMinors = [.01 2 1.25 5.5];

Xticks=[.01  .1 1  2 3];
axesMajors = [.005 1 1 4.5; ...
    3 11 48 55  ;...
    ];




IndiciesX = upper(IndiciesFig1_X);
IndiciesY = upper(IndiciesFig1_Y);

zza=1;
for kk = 1:size(IndiciesX,1)
    for n = 1:size(IndiciesX,2)
        
        
        
        xvalue = IndiciesX(kk,n);
        yvalue = IndiciesY(kk,n);
        
        
        [a,xindice]=(ismember(xvalue, upper(targetStrings_Trace)));
        [a,iiiy]=(ismember(yvalue, upper(Elements)));
        
        
        xxvalue = xindice;
        yyvalue = iiiy;
        
        
        
        subaxis(3,2,5)
        axis(axesMajors(1,:))
        
        hold on
        axis square
        
        DataX = interp1( [0 1], xlim(), .001);
        DataY = interp1( [0 1], ylim(), .9 );
        text(DataX, DataY, 'E)','fontsize', 12,'FontName','Times New Roman')
        
        
        
        
        
        
        %                 plot(DataRatios_GALEsheet(ultraslowspreadingMORBS,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
        %                 DataRatios_GALEsheet(ultraslowspreadingMORBS,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
        %                 'o', 'color','m', 'markerfacecolor','m','markersize',6)
        % %
        %                 plot(DataRatios_GALEsheet(slowspreadingMORBS,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
        %                 DataRatios_GALEsheet(slowspreadingMORBS,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
        %                 'o', 'color','c', 'markerfacecolor','c','markersize',3)
        % %
        %                       plot(DataRatios_GALEsheet(intermediatespreadingMORBS,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
        %                 DataRatios_GALEsheet(intermediatespreadingMORBS,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
        %                 'o', 'color','r', 'markerfacecolor','r','markersize',3)
        %
        %                 plot(DataRatios_GALEsheet(fastspreadingMORBS,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
        %                 DataRatios_GALEsheet(fastspreadingMORBS,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
        %                 'o', 'color','g', 'markerfacecolor','g','markersize',3)
        %
        
        %                 plot(DataRatios_GALEsheet(slowspreadingMORBS,xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
        %                 DataRatios_GALEsheet(slowspreadingMORBS,yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
        %                 'o', 'color','r', 'markerfacecolor','r','markersize',1)
        
 
        
        
        %             test1 = hline(DataRatios_TraceDMM(yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),'k-');
        %             test2=vline(DataRatios_TraceDMM(xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),'k-');
        %             uistack(test1,'bottom')
        %             uistack(test2,'bottom')
        %
        %
        %                     h1=plot(Avg_Gale_Trace(:,xxvalue),Avg_Gale(:,yyvalue)...
        %                         ,'o','Color',grey8,'LineWidth',0.1,'MarkerSize',4,'MarkerFaceColor',grey8);
        %
        %                     h2=plot(Avg_Gale_Trace(emorbs1,xxvalue),Avg_Gale(emorbs1,yyvalue)...
        %                         ,'o','Color',grey5,'LineWidth',0.1,'MarkerSize',4,'MarkerFaceColor',grey5);
        %
        %
        
        if strcmp(galeon,'yes')==1
            h1=plot(Gale_5_Master_TE_Iso_Edited_Trace(:,xxvalue),Gale_5_Master_TE_Iso_Edited(:,yyvalue)...
                ,'o','Color',grey8,'LineWidth',0.1,'MarkerSize',2,'MarkerFaceColor',grey8);
            
            
            h1=plot(Gale_5_Master_TE_Iso_Edited_Trace(emorbs1_re,xxvalue),Gale_5_Master_TE_Iso_Edited(emorbs1_re,yyvalue)...
                ,'o','Color',grey5,'LineWidth',0.1,'MarkerSize',2,'MarkerFaceColor',grey5);
        end
        %                     plot(kimberlites_Trace(:,xxvalue),kimberlites(:,11)...
        %                         ,'o','Color','r','LineWidth',0.1,'MarkerSize',4,'MarkerFaceColor','r');
        %
        %
        
        
        for zz = UniqueLabels_Rows'
            i =find(ismember(runningLabels, runningLabels(zz)));
            
            plot(runningTrace(i,xxvalue),...
                runningMajors(i,yyvalue),...
                runningMarkers{zz},'LineWidth',0.5,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'HandleVisibility','on')
            
        end
        
        % emorb : grey2 #3
        % nmorb: grey55 #1
        % dmorb grey7 #2
        
        
        %         Data_GALE_colors = {'grey4','grey55','black'};
        %         for i = 1:size(Avg_Gale,1)
        %             plot(Avg_Gale_Trace(i,xxvalue),Avg_Gale_Trace(i,yyvalue),...
        %                 'xk','LineWidth',3,'MarkerSize',15, 'Color',eval(Data_GALE_colors{i}),'MarkerFaceColor',eval(Data_GALE_colors{i}));
        %             %'o-k','LineWidth',1,'MarkerSize',12, 'Color','k','MarkerFaceColor',eval(Colors_GALE{i}));
        %         end
        
        
        
        
        for iik=1:numberModels 
            
                layerplot_color_here = eval(char(layerplot_color(iik)));
                layerplot_color_here_fill = eval(char(layerplot_color_fill(iik)));
                FCLineColors_here = eval(char(FCLineColors(iik)));
                mymarkersize = layerplot_markersize(iik);
                layerplot_marker_here = char(layerplot_marker(iik));
                layerplot_color_here_edge = eval(char(layerplot_color_edge(iik)));
            
            if any((strfind(TabNames{iik},'SM')))==1
                numdatapts = size(eval(sprintf('%s_Trace(:,%g)', TabNames{iik}, xxvalue)),1);
                layerplot_marker_here = SM_Markers;
          
                mymarkersizeSpecial = 3;
                for lll = 1:numdatapts
                    if ismember(lll,which2plot)
                        mymarkersize = SM_MarkerSize(lll) ;
                        
                        
                        plot(eval(sprintf('%s_Trace(lll,%g)', TabNames{iik}, xxvalue)),...
                            eval(sprintf('%s(lll,%g)', TabNames{iik}, yyvalue)),...
                            char(layerplot_marker_here(lll)),...
                            'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'LineWidth',linewidth,'MarkerSize',mymarkersize,'HandleVisibility','off')
                        
                        
                        
                    
                        
                        
                    end
                end
            else
                
               
                    plot(eval(sprintf('%s_Trace(:,%g)', TabNames{iik}, xxvalue)),...
                        eval(sprintf('%s(:,%g)', TabNames{iik}, yyvalue)),...
                        layerplot_marker_here,...
                        'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'MarkerEdgeColor',layerplot_color_here_edge,...
                        'LineWidth',linewidth,'MarkerSize',mymarkersize,'HandleVisibility','off');

            end
        end
        
        
        colorindex = 1;
        for iiill = 1% suball
            %indexforlenged(iii) = RidgesListIndex{iii}(1);
            clear datasmoosh;
            for jjj=1:size(Un_Trace_SegmentArrayIndex{iiill},2) %160;%
                plot(DataRatios_GALEsheet(unique_idx_trace{Un_Trace_SegmentArrayIndex{iiill}(jjj)},xxvalue)./TraceElements4Normalization_DataRatios(xxvalue),...
                    DataRatios_GALEsheet(unique_idx_trace{Un_Trace_SegmentArrayIndex{iiill}(jjj)},yyvalue)./TraceElements4Normalization_DataRatios(yyvalue),...
                    'o', 'color','k', 'markerfacecolor',colorsjetTrace(colorindex,:),'markersize',5) % GALA14 517	Galapagos
                % 'o', 'color',grey5, 'markerfacecolor',white,'markersize',8,'HandleVisibility','off') % GALA14 517	Galapagos
                
                %mostprimitivesmoosh = MostPrimitiveGaleDataIndex(RidgesListIndex{iii});
                %plot(MostPrimitiveGaleData(RidgesListIndex{iii}(jjj),xindice), MostPrimitiveGaleData(RidgesListIndex{iii}(jjj),i),'p', 'color',colorsjet(colorindex,:), 'markerfacecolor',colorsjet(colorindex,:),'markersize',10) % GALA14 517	Galapagos
                colorindex = colorindex+1;
            end
        end
        
        
        if isempty(NamesForFC) ==0
            for kjm = 1:size(NamesForFC,2)
                goodTabNames2=NamesForFC(kjm);
                
                [a2,b2]=find(ismember(TabNames,goodTabNames2));
                majorsHere = eval(sprintf('%s', TabNames{b2}));
                
                traceHere = eval(sprintf('%s_Trace', TabNames{b2}));
                traceHere(:,44)= 0.*traceHere(:,43);
                
                if ischar(layerplot_color{b2})==1
                    layerplot_color_here = eval(char(layerplot_color(b2)));
                else
                    layerplot_color_here = layerplot_color{b2};
                end
                
                if ischar(layerplot_color_fill{b2})==1
                    layerplot_color_here_fill = eval(char(layerplot_color_fill(b2)));
                      FCLineColors_here = eval(char(FCLineColors(b2)));
                else
                    layerplot_color_here_fill = layerplot_color_fill{b2};
                end
                
    
                    for layerplotnumXX = downsampeld
                        
                        
                        
                        clear testfrac testYYY
                        %[testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHereRightOrder(layerplotnum,:), 6, traceHere(layerplotnum,:),Dmatrix);
                        [testfrac,testXXX,testYYY] = YKG_wTRACE(majorsHere(layerplotnumXX,:),PetrogenMajorElement_Strings_Extracted, PfracXtal, traceHere(layerplotnumXX,:),Dmatrix);
                        
                        
                        f= [testfrac(:,MgOcolumn)];
                        val = 6; %value to find
                        tmp = abs(f-val);
                        [idx idy] = min(tmp); %index of closest value
                        closest = idy;
                        %testXXX(:,44)=[];
                        clear DataRatios
                        
                        
                 
                        if ismember(layerplotnumXX,[1 2 3])==1
                            
                            plot(testXXX(1:closest,xxvalue),...
                                testfrac(1:closest,9),...
                                YKGcharNF,'Color',FCLineColors_here,'LineWidth',2);
                            
                            
                        else if ismember(layerplotnumXX,[10 11])==1
                                
                                plot(testXXX(1:closest,xxvalue),...
                                    testfrac(1:closest,9),...
                                    YKGcharPool,'Color',FCLineColors_here,'LineWidth',2);
                                
                                
                                
                            else if ismember(layerplotnumXX,[4 5 6])==1
                                    
                                    plot(testXXX(1:closest,xxvalue),...
                                        testfrac(1:closest,9),...
                                        YKGcharNF,'Color',FCLineColors_here,'LineWidth',2);
                                    
                                else if ismember(layerplotnumXX,[7 8 9])==1
                                        plot(testXXX(1:closest,xxvalue),...
                                            testfrac(1:closest,9),...
                                            YKGcharNF,'Color',red,'LineWidth',2);
                                        
                            
                                end
                            end
                        end
                        
                    end
                end
            end
        end
        
        
        xlabel(sprintf('%s ppm',xvalue{:}));
        ylabel(sprintf('%s wt%',yvalue{:}));
        ylabel('Na_2O (wt%)');
        
        
        box on
        
        axis square
        set(gca,'ticklength',2*[0.0200    0.0500])
        %set(gca,'ticklength',2*get(gca,'ticklength'))
        set(gca,'fontsize', 17,'LineWidth',0.7,'FontName','Times New Roman')
        set(gca,'XColor', 'k')
        set(gca,'YColor', 'k')
        ax = gca;
        ax.XAxis.MinorTick = 'on';
        if logon ==1
            %set(gca,'yscale','log')
            set(gca,'xscale','log')
            set(gca, 'Xtick',unique([axesMinors(1:2) Xticks]))
            
            curtick = get(gca, 'XTick');
            set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
            
              ax.XAxis.MinorTickValues = [.001:.001:.01 .02:.01:.1 .2:.1:1 2:1:10];
            
        end
        
        %set(gca, 'Xtick',1500:10:1540)
        
        
        
        
        %         set(gca, 'Ytick',unique([axesMinors(n,3:4) Yticks{n}]))
        %         set(gca, 'Xtick',unique([axesMinors(n,1:2) Xticks{n}]))
        %
        %         curtick = get(gca, 'XTick');
        %         set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
        %         curtick = get(gca, 'YTick');
        %         set(gca, 'YTickLabel', cellstr(num2str(curtick(:))));
        %
        
        
        ax.YAxis.MinorTick = 'on';
        %     increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
        %  ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
        %set(ax,'XMinorTick','on')
        
        %set(gca, 'Ytick',[.4 .6 .8  1 1.2 1.4  1.6 1.8 2 2.2 3 ])
        
      if strcmp(yvalue,'NA2O')
            set(gca, 'Ytick',0:.5:10)
            increment = .25;
            ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
        end
        
        
        % if n == 3
        %
        %    ax.YAxis.MinorTickValues = [[axesMinors(n,1):.001:.01] [.02:.1:3] ];%[2:1:axesMinors(n,2)]
        % end
    end
end




%%



for n=1:6
    subaxis(3,2,n)
    hold on
    set(gca,'ticklength',2*[0.0200    0.0500])
    set(gca,'fontsize', 13,'LineWidth',.7,'FontName','Times New Roman')
    set(gca,'XColor', 'k')
    set(gca,'YColor', 'k')
    
end



runhere = eval(sprintf('%s_Info', goodTabNames{3}));
phihere = runhere(1,2).*100;
Tphere = runhere(1,4);
Waterhere = runhere(1,3);
Bulkhere = runhere(1,6);
'ZETA POOL percent'
ZETApool = runhere(1,13)*100


sourcehere= unique(layerplot_TESource);
meltmodelname=sprintf('%s=%.1f%% T_P=%d%sC %dppm H_2O \n Bulk#%d, %s','\phi',phihere,Tphere,'\circ',Waterhere,Bulkhere,sourcehere{:});
meltmodelname1 = '\it \phi=1% T_P=1300\circC 300ppm H_2O';
meltmodelname2 = '\it Bulk#17, WH DMM';


subaxis(3,2,5)
text(.005,1.5,meltmodelname,'fontsize', 13,'FontName','Times New Roman','color',grey5)
%text(.005,.7,meltmodelname2,'fontsize', 17,'FontName','Times New Roman')
